const app = getApp();
Page({
  data: {
    StatusBar: app.globalData.StatusBar,
    CustomBar: app.globalData.CustomBar,
    userInfo:[],
    sex:'',
    color_list:['cyan','blue','green','olive'],
    member_tag:[],
  },

  onShow:function(){
    let _this = this;
    _this.getUserInfo(); //获取账户信息
  },


  //获取个人信息
  getUserInfo:function(){
    let _this = this,
     sex = _this.data.sex,
     member_tag = _this.data.member_tag;
    wx.showLoading({
      title: '加载中',
    })
    app._post('api/member/getUserInfo', {}, function(result) {
      wx.hideLoading({})
      if(result.code == 200){
        if(result.data.sex == 1){
          sex = '男';
        }else if(result.data.sex == 2){
          sex = '女';
        }else{
          sex = '未知';
        }

        if(result.data.tag_list.length > 0){
          member_tag = result.data.tag_list.split(',')
        }
        console.log(member_tag)
        _this.setData({
          userInfo:result.data,
          sex:sex,
          member_tag:member_tag
        })
        wx.hideLoading();
      }else{
        wx.navigateTo({
          url: '../auth/auth'
        })
      }
    });
  },
})